import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import ys from 'vite-plugin-compression'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(),
    ys({
      algorithm:'gzip'
    }),{
      name:'my-plugin',transform(code){
        return code.replace(/console\.log/g,'console.info')
      }
    }
  ],
  resolve:{
    alias:{
      '@':path.resolve(__dirname,'src')
    }
  },
  // 移除console
  esbuild:{
    drop:['console','debugger']
  },
  server: {
    proxy: {
      '^/api': {
        target: 'http://172.27.2.110',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    }
  }
})
// gzip压缩
// 将console.log换成console.info
// 移除console